<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app">{{name}}</div>
    <script src="../dist/vue.js"></script>
    <!-- 组件化的优点：复用、好维护、核心组件级更新 组件的三大特性 属性 样式 插槽 webcomponent -->
    <script>
      let vm = new Vue({
        el: "#app",
        data: {
          name: "hulei",
        },
        watch: {
          name(newValue, oldValue) {
            console.log(newValue, oldValue);
          },
        },
      });
      vm.$watch("name", (newValue, oldValue) => {
        console.log(newValue, oldValue);
      });
      setTimeout(() => {
        vm.name = "hello";
      }, 1000);
    </script>
  </body>
</html>
